/*                          UX-Framework                               
 *                                                                 
 *  iZE Co.,Ltd. Copyright 2009 All rights reserved.          
 *  This file is distributed under the terms of the GNU Lesser 
 *  General Public License, described in file LICENSE.                                     
 */
package jp.ize.ux.components.themes.basic;

// {{{ imports
import jp.ize.ux.components.UXResource;
import jp.ize.ux.components.UXComponentResource;
import jp.ize.ux.geom.UXSize;
import flash.display.MovieClip;
import flash.display.GradientType;
import flash.geom.Matrix;
// }}}
// {{{ class UXProgressBarResource
/** 
 * UXProgressBarResource クラス<br>
 * コンポーネントの描画に利用されるリソース情報です。<br>
 *
 * @author		iZE Co., Ltd.<br>
 * @version		$Id: UXProgressBar.hx 20 2009-02-04 08:23:19Z yimai.v $<br>
 */
class UXProgressBarResource extends UXComponentResource
{
	// {{{ properties

	public var size:UXSize;
	public var color:Int;

	// }}}
	// {{{ public function new( size:UXSize, color:Int, ?res:Dynamic ) : Void
	/**
	* コンストラクタ
	*/
	public function new( size:UXSize, color:Int, ?res:Dynamic ) : Void
	{
		this.color = color;
		super(res,false);
		this.size = size;
	}

	// }}}
	// {{{ public static function getBackground( size:UXSize ) : UXComponentResource

	public static function getBackground( size:UXSize ) : UXComponentResource
	{
		var mc = new MovieClip();
		var comres = new UXComponentResource(mc);
		return comres;
	}

	// }}}
	// {{{ public static function getTrack( size:UXSize ) : UXComponentResource

	public static function getTrack( size:UXSize ) : UXComponentResource
	{
		var mc = new MovieClip();
		// {{{ design
		//var colors:Array<UInt> = [ 0x333333, 0x666666, 0x666666, 0x333333 ];
		//var alphas:Array<Dynamic> = [ 1.0, 1.0, 1.0, 1.0 ];
		//var ratios:Array<UInt> = [ 0, 64, 192, 255 ];
		//var matrix:Matrix = new Matrix();
		//matrix.createGradientBox( size.width, size.height, Math.PI/2 );

		var g = mc.graphics;
		g.clear();
		g.lineStyle( 1.0, 0x999999 );
		//g.beginGradientFill( GradientType.LINEAR, colors, alphas, ratios, matrix );
		g.beginFill( 0xAAAAAA );
		g.drawRect( 0, 0, size.width, size.height );
		g.endFill();
		var ty = 3;
		g.beginFill( 0x888888 );
		g.drawRect( 0, ty, size.width, size.height-ty*2 );
		g.endFill();
		// }}}
		var comres = new UXComponentResource(mc);
		return comres;
	}

	// }}}
	// {{{ public static function getBar( size:UXSize ) : UXComponentResource

	public static function getBar( size:UXSize ) : UXComponentResource
	{
		var mc = new MovieClip();
		// {{{ design
		var ty = 3;
		//var colors:Array<UInt> = [ 0x000000, 0x00FF00, 0x66FF66, 0x00FF00, 0x000000 ];
		//var alphas:Array<Dynamic> = [ 1.0, 1.0, 1.0, 1.0, 1.0 ];
		//var ratios:Array<UInt> = [ 0, 64, 128, 192, 255 ];
		var colors:Array<UInt> = [ 0x99FF99, 0x00FF00 ];
		var alphas:Array<Dynamic> = [ 1.0, 1.0 ];
		var ratios:Array<UInt> = [ 0, 255 ];
		var matrix:Matrix = new Matrix();
		matrix.createGradientBox( size.width, size.height-ty*2, Math.PI/2, 0, ty );

		var g = mc.graphics;
		g.clear();
		g.lineStyle( 1.0, 0x999999 );
		g.beginGradientFill( GradientType.LINEAR, colors, alphas, ratios, matrix );
		g.drawRect( 0, ty, size.width, size.height-ty*2 );
		g.endFill();
		// }}}
		var comres = new UXComponentResource(mc);
		return comres;
	}

	// }}}
}
// }}}
